<template>
<div class="newsinfo-container">
    <h3 class="title">{{newInfor.title}}</h3>
    <p class="subtitle">
        <span>发表时间：{{newInfor.add_time |dateFormat}}</span>
        <span>点击：{{newInfor.click}}次</span>
    </p>
    <!-- 内容区域 -->
    <div class="content" v-html="newInfor.content"></div>

    <comment></comment>
</div>
</template>

<script>
import comment from '../subcomponents/comment.vue'
import {
    Toast
} from 'mint-ui'
export default {
    data() {
        return {
            newInfor: [],
            id: this.$route.params.id
        }
    },
    created() {
        this.getNewsInfo()
    },
    methods: {
        async getNewsInfo() {
            const {
                data: res
            } = await this.$http.get('/api/getnew/' + this.id)
            console.log(res)
            if (res.status == 0) {
                Toast('成功')
                this.newInfor = res.message[0];
            } else {
                Toast(res.message)
            }
        }
    },
    components: {
        // 用来注册子组件的节点
        comment
    }
}
</script>
  

  
<style scoped>
.newsinfo-container {
    padding: 0 4px;
}

.newsinfo-container .title {
    font-size: 16px;
    text-align: center;
    margin: 15px 0;
    color: red;
}

.newsinfo-container .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
}

/deep/img {
    width: 100%;
}
</style>
